package com.guoxue.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.guoxue.dao.IBookConfigDao;
import com.guoxue.domain.BookConfigVo;
@Repository
public class BookConfigDaoImpl extends BaseDaoImpl<BookConfigVo> implements IBookConfigDao{

	@Override
	public void saveBookConfig(BookConfigVo bc) {
		saveOrUpdate(bc);
	}

	@Override
	public List<BookConfigVo> getBookConfigList() {
		return find("From BookConfigVo");
	}

	@Override
	public void deleteBook(int id) {
		executeHql("DELETE FROM BookConfigVo b WHERE b.bookId=?", new Object[] {id});
	}

	@Override
	public BookConfigVo getBookConfigById(int bookId) {
		return get("From BookConfigVo b WHERE b.bookId=?", new Object[] {bookId});
	}

	@Override
	public BookConfigVo getBookByChapterId(int chapterId) {
		return get("From BookConfigVo b WHERE b.beginChapterId<=? AND b.endChapterId>=?", new Object[] {chapterId,chapterId});
	}

}
